﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace aaaSoft.SkinEngine.SkinHelpers
{
    class ResourceHelper
    {
        /// <summary>
        /// 获取资源图片，返回Bitmap
        /// </summary>
        /// <param name="bmpName"></param>
        /// <returns></returns>
        public static Bitmap GetBitmapResource(String bmpName)
        {
            Bitmap bmp = (Bitmap)GetObjectResource(bmpName);
            return new Bitmap(bmp, bmp.Size);
        }
        /// <summary>
        /// 获取资源对象，返回Object
        /// </summary>
        /// <param name="objName"></param>
        /// <returns></returns>
        public static Object GetObjectResource(String objName)
        {
            System.Reflection.Assembly ass = System.Reflection.Assembly.GetCallingAssembly();
            System.Resources.ResourceManager rm = new System.Resources.ResourceManager("aaaSoft.SkinEngine.Properties.Resources", ass);
            return System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(rm.GetObject(objName));
        }
    }
}
